home *** CD-ROM | disk | FTP | other *** search
/ ftp.cs.arizona.edu / ftp.cs.arizona.edu.tar / ftp.cs.arizona.edu / icon / newsgrp / group93b.txt / 000110_icon-group-sender _Thu May 20 14:37:07 1993.msg < prev    next >
Internet Message Format  |  1993-06-16  |  2KB

  1. Received: from owl.CS.Arizona.EDU by cheltenham.cs.arizona.edu; Fri, 21 May 1993 10:50:18 MST
  2. Received: by owl.cs.arizona.edu; Fri, 21 May 1993 10:50:17 MST
  3. Date: 20 May 93 14:37:07 GMT
  4. From: agate!spool.mu.edu!uwm.edu!msuinfo!uchinews!ellis!goer@ucbvax.Berkeley.EDU  (Richard L. Goerwitz)
  5. Organization: University of Chicago
  6. Subject: Re: A bug? Or a feature?
  7. Message-Id: <1993May20.143707.20031@midway.uchicago.edu>
  8. References: <12743@sun13.scri.fsu.edu>, <26810@ksr.com>
  9. Sender: icon-group-request@cs.arizona.edu
  10. To: icon-group@cs.arizona.edu
  11. Status: R
  12. Errors-To: icon-group-errors@cs.arizona.edu
  13.  
  14. In article <26810@ksr.com> tim@ksr.com (Tim Peters) writes, regarding
  15. the form X1 op:= X2:
  16.  
  17. >There's another (well, at least one more) ambiguity in the text you
  18. >quote, to wit how many times X1 is evaluated.  An example to show the
  19. >difference:
  20.  
  21. >      pick() +:= 10
  22. >      pick() := pick() + 10
  23. >
  24. >procedure pick()
  25. >   static i
  26. >   initial i := 0
  27. >   case i +:= 1 of {
  28. >      1 : return i1
  29. >      2 : return i2
  30. >   }
  31. >end
  32.  
  33. ...
  34.  
  35. >The point is that the left-hand side is evaluated exactly once in an
  36. >augmented assignment, & I'm not sure The Bible ever says that except for
  37. >an implication on pg 74...
  38.  
  39. Another good point.  What Icon does is invoke the function pick(), and
  40. when its value returns (at which point it is on the top of the stack),
  41. it simply duplicates that value.  That value is a variable.  The value
  42. is duplicated so it can be used once for assignment and once for ad-
  43. dition.  Pick() is invoked once, in other words - like Tim says.
  44.  
  45. I can imagine unpleasant side-effects if things didn't work this way.
  46.  
  47. -- 
  48.  
  49.    -Richard L. Goerwitz              goer%midway@uchicago.bitnet
  50.    goer@midway.uchicago.edu          rutgers!oddjob!ellis!goer
  51.